package com.lqd.mall.system.service.factory;

import com.lqd.mall.basis.response.Result;
import com.lqd.mall.interaction.system.vo.LoginUserVo;
import com.lqd.mall.system.service.RemoteUserService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 零起点
 * @create 2022-02-20 0:16
 */
@Slf4j
public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserService> {
    @Override
    public RemoteUserService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteUserService() {
            @Override
            public Result<LoginUserVo> getUserInfo(String name, String source) {
                return  Result.FAIL("获取用户失败:"+throwable.getMessage(),new LoginUserVo());
            }
        };
    }
}
